package jinyilw.swing.visuals.Icomp;

import jinyilw.swing.i18n.ICSetting;
import jinyilw.swing.i18n.LanguageChanger;
import jinyilw.swing.rlaf.ui.RButtonUI;

import javax.swing.Action;
import javax.swing.JButton;
import java.awt.Color;

public class IButton extends JButton implements LanguageChanger
{
	private static final long serialVersionUID = 39082560987930759L;
	private RButtonUI rButtonUI;
	private ICSetting i18nSetting;

	public IButton()
	{
	}

	public IButton(String text)
	{
		super(text);
	}

	public IButton(Action a)
	{
		super(a);
	}

	public IButton(ICSetting iSetting)
	{
		setText(iSetting);
	}

	public void setDefaultAlpha(float alpha)
	{
		rButtonUI.setDefaultAlpha(alpha);
	}

	public void setHoverAlpha(float alpha)
	{
		rButtonUI.setHoverAlpha(alpha);
	}

	public void configAlpha(float dAlpha, float hAlpha)
	{
		rButtonUI.configAlpha(dAlpha, hAlpha);
	}

	public void setGradientColor(Color color1, Color color2)
	{
		rButtonUI.setGradientColor(color1, color2);
	}

	public void setRound(int round)
	{
		rButtonUI.setRound(round);
	}

	@Override
	public void updateUI()
	{
		if (rButtonUI == null)
			rButtonUI = new RButtonUI();
		setUI(rButtonUI);
	}

	public void setICSetting(ICSetting iSetting)
	{
		i18nSetting = iSetting;
	}

	@Override
	public ICSetting getICSetting()
	{
		return i18nSetting;
	}

	@Override
	public void updateText(String text)
	{
		setText(text);
	}
}
